package com.neusoft.ysu.npms.controller;


import com.neusoft.ysu.npms.pojo.Department;
import com.neusoft.ysu.npms.pojo.Log;
import com.neusoft.ysu.npms.pojo.Measure;
import com.neusoft.ysu.npms.pojo.Result;
import com.neusoft.ysu.npms.service.ILogService;
import com.neusoft.ysu.npms.service.impl.MeasureServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 作者：刘金秋
 * @since 2024-06-18
 */
@RestController
@RequestMapping("/log")
public class LogController {
    @Autowired
    private ILogService logService;

    @RequestMapping("/add")
    public Result add(@RequestBody Log log) {
//        System.out.println(department);
        logService.add(log);
        return Result.success();
    }

    @RequestMapping("/delete")
    public Result delete(@RequestBody Map<String, Object> body){
        System.out.println(body.get("logid"));
        return logService.deleteByLogId((int)body.get("logid"));
        //return Result.success();
    }

    @RequestMapping("/update")
    public Result update(@RequestBody Log log){
        logService.updateByLogId(log);
        return Result.success();
    }
    @RequestMapping("/getAll")
    public Result getAll(){
        logService.selectAll();
        return Result.success();
    }

    @RequestMapping("/findone")
    public Result findone(@RequestBody Log log){
        System.out.println(log);
        logService.findById(log);
        return Result.success();
    }

}
